﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
using SaleStat.COM.SQLHelper;
using SaleStat.COM.Constant;
using SaleStat.COM.Exceptions;
using System.Data;
using SES.COM.SQLHelper;
namespace SaleStat.BLL.PM
{
    public class PM_Edit_BLL
    {
        #region 全局定义
        /// <summary>
        /// XML文件名
        /// </summary>
        private string _XML_NAME = "PM";
        private const string FORMAT_STYLE = "0000";
        #endregion

        #region 更新产品信息
        /// <summary>
        /// 更新产品信息
        /// </summary>
        /// <param name="arrParam"></param>
        /// <returns></returns>
        public int updateProductInfo(ArrayList arrParam)
        {
            return DbHelper.ExecuteNonQuery(_XML_NAME, SqlKeyConstant.PM_SQL004_U, arrParam);
            
        }
        #endregion

        #region 取得产品信息
        /// <summary>
        /// 取得产品信息
        /// </summary>
        /// <param name="strCpID"></param>
        /// <returns></returns>
        public DataTable getProductInfo(string strCpID)
        {
            ArrayList arrParam = new ArrayList();
            arrParam.Add(strCpID);
            DataTable dtCustomInfo = DbHelper.ExecuteDataTable(_XML_NAME, SqlKeyConstant.PM_SQL003_R, arrParam);
            return dtCustomInfo;
        }
        #endregion

        #region  获取产品MaxID
        /// <summary>
        ///   获取产品MaxID
        /// </summary>
        /// <returns></returns>
        public string getMaxProductID()
        {
            string strFinalMaxID = null;
            string strMaxID = DbHelper.ExecuteScalar(_XML_NAME, SqlKeyConstant.PM_SQL006_R).ToString();
            //判断是否是第一次插入
            if (string.IsNullOrEmpty(strMaxID))
            {
                strFinalMaxID = "PM0001";
            }
            //自动+1
            else
            {

                int intMaxID = Convert.ToInt32(strMaxID.Substring(2, 4)) + 1;
                strFinalMaxID = "PM" + intMaxID.ToString(FORMAT_STYLE);
            }
            return strFinalMaxID;
        
        }
        #endregion 


        #region  插入产品信息
        public int insertProductInfo(ArrayList arrParam)
        {
            return DbHelper.ExecuteNonQuery(_XML_NAME, SqlKeyConstant.PM_SQL005_I, arrParam);
        
        }
        #endregion 
    }
}
